//
//  MyIntegralCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/4.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "MyIntegralCell.h"

@interface MyIntegralCell ()

@property (nonatomic, strong) UILabel *eventLabel;
@property (nonatomic, strong) UILabel *moneyLabel;
@property (nonatomic, strong) UILabel *timeLabel;

@end

@implementation MyIntegralCell

- (void)setIntegralModel:(IntegralModel *)integralModel {
    _integralModel = integralModel;
    
    self.timeLabel.text = integralModel.time;
    self.eventLabel.text = integralModel.way_name;
    if ([integralModel.type integerValue] == 1) {
        self.moneyLabel.text = [NSString stringWithFormat:@"+%@",integralModel.amount];
    }else {
        self.moneyLabel.text = [NSString stringWithFormat:@"-%@",integralModel.amount];
    }
}

+ (MyIntegralCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"MyIntegralCell";
    MyIntegralCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[MyIntegralCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    self.eventLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(13), ScreenX375(220), ScreenX375(18))];
    self.eventLabel.textColor = REXADECIMALCOLOR(@"#333333");
    self.eventLabel.font = Kfont(14);
    self.eventLabel.text = @"完善个人信息获得积分";
    [self addSubview:self.eventLabel];
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(35), ScreenX375(220), ScreenX375(14))];
    self.timeLabel.textColor = REXADECIMALCOLOR(@"#999999");
    self.timeLabel.font = Kfont(12);
    self.timeLabel.text = @"2018-05-25  15:40:50";
    [self addSubview:self.timeLabel];
    
    self.moneyLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - ScreenX375(73), ScreenX375(16), ScreenX375(60), ScreenX375(14))];
    self.moneyLabel.textColor = ThemeColor;
    self.moneyLabel.font = Kfont(12);
    self.moneyLabel.textAlignment = NSTextAlignmentRight;
    self.moneyLabel.text = @"+100";
    [self addSubview:self.moneyLabel];
    
    UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(56) - 0.5, SCREEN_WIDTH - ScreenX375(26), 0.5)];
    line.image = [UIImage imageNamed:@"虚线"];
    [self addSubview:line];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end

@implementation IntegralModel

+(JSONKeyMapper*)keyMapper
{
    return [[JSONKeyMapper alloc] initWithModelToJSONDictionary:@{
                                                                  @"Id": @"id",
                                                                  }];
}

@end
